<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var s = "({})";
        var isValid = function(s){
        var map = new Map()
        map.set('(',')');
        map.set('{','}');
        map.set('[',']');
        var res = [];
        for(var i =0;i<s.length;i++){
            if(map.has(s[i])){
                res.push(map.get(s[i]))
            }
            else{
                if(res.pop()!=s[i]){
                    return false;
                }
            }     
            
        }
     
        return res.length==0
        }
        console.log(isValid(s))

    </script>
</body>
</html>